//
//  HeaderDefinition.h
//  WY_Master
//
//  Created by wangyang on 2019/12/4.
//  Copyright © 2019 wangyang. All rights reserved.
//

#ifndef HeaderDefinition_h
#define HeaderDefinition_h

#define WySCREENWIDTH [[UIScreen mainScreen] bounds].size.width
#define WySCREENHEIGHT [[UIScreen mainScreen] bounds].size.height

/// View 圆角
#define WyViewRadius(View, Radius)\
\
[View.layer setCornerRadius:(Radius)];\
[View.layer setMasksToBounds:YES]

///  View加边框
#define WyViewBorder(View, BorderColor, BorderWidth )\
\
View.layer.borderColor = BorderColor.CGColor;\
View.layer.borderWidth = BorderWidth;

#define UIColorFromRGB(rgbValue) [UIColor colorWithRed:((float)((rgbValue & 0xFF0000) >> 16))/255.0 green:((float)((rgbValue & 0xFF00) >> 8))/255.0 blue:((float)(rgbValue & 0xFF))/255.0 alpha:1.0]

#define NavGBGColor UIColorFromRGB(0x1E1E1E)
#define   WyWhiteColor   [UIColor whiteColor]
#define   WyBlackColor   [UIColor blackColor]


#define StringNull(str) ([str isKindOfClass:[NSNull class]]||str == nil||[[NSString stringWithFormat:@"%@",str] length] < 1||[[NSString stringWithFormat:@"%@",str] isEqualToString:@"(null)"]||[[NSString stringWithFormat:@"%@",str] isEqualToString:@"<null>"])

///导航栏高度
#define NavViewHeight        (CNavigationStatusHeight+tabBerHeight)
//刘海屏状态栏高度是44，其他是20
#define CNavigationStatusHeight ([[UIApplication sharedApplication] statusBarFrame].size.height>20?88:64)
//底部选项卡的高度
#define tabBerHeight self.navigationController.tabBarController.tabBar.frame.size.height

//底部安全距离
#define SafeDistanceHeight ([[UIApplication sharedApplication] statusBarFrame].size.height>20?74:44)

//刘海屏状态栏高度是44，其他是20
#define CStatusBarHeight [[UIApplication sharedApplication] statusBarFrame].size.height
#define CNavBarHeight 44.0
#define CTabBarHeight ([[UIApplication sharedApplication] statusBarFrame].size.height>20?83:49)
#define CTopHeight (CStatusBarHeight + CNavBarHeight)
#define CTopDifferenceHeight (CStatusBarHeight - 20)

//强弱引用
#define kWeakSelf(type)  __weak typeof(type) weak##type = type;
#define kStrongSelf(type) __strong typeof(type) type = weak##type;

//获取
#define GetUD(key) [[NSUserDefaults standardUserDefaults] valueForKey:key]
//赋值
#define SetUD(value,key) [[NSUserDefaults standardUserDefaults] setObject:value forKey:key]
//删除
#define RemoveUD(key) [[NSUserDefaults standardUserDefaults] removeObjectForKey:key]

//状态栏高度
//#define statusBarHeight [[UIApplication sharedApplication] statusBarFrame].size.height

//导航栏的高度
#define navigationBarHeight self.navigationController.navigationBar.frame.size.height
///导航栏高度
#define NavViewHeight        (CNavigationStatusHeight+tabBerHeight)

//底部选项卡的高度
#define tabBerHeight self.navigationController.tabBarController.tabBar.frame.size.height
#define THfloat(a) a*THWParam

#define THWParam [UIScreen mainScreen].bounds.size.width/375.0f

#define THfloat(a) a*THWParam

#define THMargin THfloat(15)

#define TocompareWith 375.0
///当前宽375  比例
#define BiLiWidth(w) ([UIScreen mainScreen].bounds.size.width/TocompareWith*w)

#define WyColor [UIColor colorWithRed:arc4random()%256/255.0 green:arc4random()%256/255.0 blue:arc4random()%256/255.0 alpha:1.0]

//刘海屏状态栏高度是44，其他是20
#define CNavigationStatusHeight ([[UIApplication sharedApplication] statusBarFrame].size.height>20?88:64)

#define HEXCOLOR(c) [UIColor colorWithRed:((c>>16)&0xFF)/255.0 green:((c>>8)&0xFF)/255.0 blue:(c&0xFF)/255.0 alpha:1.0]
#define colorBlue   HEXCOLOR(0x00C3F5)
#define colorWhite  HEXCOLOR(0xFFFFFF)

//
#define INTERFACE_IS_IPHONEX (@available(iOS 11.0, *) && ([UIApplication sharedApplication].keyWindow.safeAreaInsets.bottom > 0)?YES:NO)
//为刘海屏 新增两个宏定义导航栏和工具栏的高度
#define nav_Height (INTERFACE_IS_IPHONEX ? 88 : 64)
#define tabBar_Height (INTERFACE_IS_IPHONEX ? 83 : 49)
// 判断是否是iPhone X
#define iPhoneX ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(1125, 2436), [[UIScreen mainScreen] currentMode].size) : NO)
//判断iPhoneX，Xs（iPhoneX，iPhoneXs）
#define IS_IPHONE_X ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(1125, 2436), [[UIScreen mainScreen] currentMode].size) : NO)
//判断iPhoneXr
#define IS_IPHONE_Xr ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(828, 1792), [[UIScreen mainScreen] currentMode].size)  : NO)
//判断iPhoneXsMax
#define IS_IPHONE_Xs_Max ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(1242, 2688), [[UIScreen mainScreen] currentMode].size) : NO)
#define IS_PhoneXAll (IS_IPHONE_X || IS_IPHONE_Xr || IS_IPHONE_Xs_Max)
/** 顶部安全距离 */

#define kSafeAreaTop ({\
CGFloat statusBarHeight = 0.;\
if(IS_PhoneXAll)statusBarHeight = 24.;\
statusBarHeight;\
})

#define BOLDSYSTEMFONT(FONTSIZE)[UIFont boldSystemFontOfSize:FONTSIZE]
#define WySYSTEMFONT(FONTSIZE)    [UIFont systemFontOfSize:FONTSIZE]
#define FONT(NAME, FONTSIZE)    [UIFont fontWithName:(NAME) size:(FONTSIZE)]

#endif /* HeaderDefinition_h */
